home *** CD-ROM | disk | FTP | other *** search
/ Aminet 23 / Aminet 23 (1998)(GTI - Schatztruhe)[!][Feb 1998].iso / Aminet / misc / emu / amiSPIMsrc.lha / spim.h < prev    next >
C/C++ Source or Header  |  1994-01-17  |  5KB  |  258 lines

  1. /* SPIM S20 MIPS simulator.
  2.    Definitions for the SPIM S20.
  3.    Copyright (C) 1990-1994 by James Larus (larus@cs.wisc.edu).
  4.    ALL RIGHTS RESERVED.
  5.  
  6.    SPIM is distributed under the following conditions:
  7.  
  8.      You may make copies of SPIM for your own use and modify those copies.
  9.  
  10.      All copies of SPIM must retain my name and copyright notice.
  11.  
  12.      You may not sell SPIM or distributed SPIM in conjunction with a
  13.      commerical product or service without the expressed written consent of
  14.      James Larus.
  15.  
  16.    THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  17.    IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  18.    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19.    PURPOSE. */
  20.  
  21.  
  22. /* $Header: /home/primost/larus/Software/SPIM/RCS/spim.h,v 3.20 1994/01/18 03:21:45 larus Exp larus $
  23. */
  24.  
  25. #ifndef NULL
  26. #define NULL 0
  27. #endif
  28.  
  29.  
  30. #define streq(s1, s2) !strcmp(s1, s2)
  31.  
  32.  
  33. /* Round V to next greatest B boundary */
  34.  
  35. #define ROUND(V, B) (((int) V + (B-1)) & ~(B-1))
  36.  
  37.  
  38. /* Sign-extend a short to a long */
  39.  
  40. #define SIGN_EX(X) ((X) & 0x8000 ? (X) | 0xffff0000 : (X))
  41.  
  42.  
  43. #define MIN(A, B) ((A) < (B) ? (A) : (B))
  44.  
  45. #define MAX(A, B) ((A) > (B) ? (A) : (B))
  46.  
  47.  
  48. #define K 1024
  49.  
  50.  
  51. /* Useful and pervasive declarations: */
  52.  
  53. #ifdef __STDC__
  54. #include <stdlib.h>
  55. #include <string.h>
  56. void bzero (void *, size_t);
  57. void bcopy (const void *, void *, size_t);
  58. #define QSORT_FUNC int(*)(const void *, const void *)
  59. #else
  60. double atof ();
  61. int atoi ();
  62. void bzero ();
  63. void bcopy ();
  64. int free ();
  65. char *malloc ();
  66. int strcmp ();
  67. char *strcpy ();
  68. char *strncpy ();
  69. #define QSORT_FUNC int(*)()
  70. #endif
  71.  
  72.  
  73.  
  74. /* Type of a memory address. */
  75.  
  76. typedef unsigned long mem_addr;
  77.  
  78.  
  79. #define BYTES_PER_WORD 4    /* On the MIPS processor */
  80.  
  81.  
  82. /* Sizes of memory segments. */
  83.  
  84. /* Initial size of text segment. */
  85.  
  86. #ifndef TEXT_SIZE
  87. #define TEXT_SIZE    256*K    /* 1/4 MB */
  88. #endif
  89.  
  90. /* Initial size of k_text segment. */
  91.  
  92. #ifndef K_TEXT_SIZE
  93. #define K_TEXT_SIZE    64*K    /* 64 KB */
  94. #endif
  95.  
  96. /* The data segment must be larger than 64K since we immediate grab
  97.    64K for the small data segment pointed to by $gp. The data segment is
  98.    expanded by an sbrk system call. */
  99.  
  100. /* Initial size of data segment. */
  101.  
  102. #ifndef DATA_SIZE
  103. #define DATA_SIZE    256*K    /* 1/4 MB */
  104. #endif
  105.  
  106. /* Maximum size of data segment. */
  107.  
  108. #ifndef DATA_LIMIT
  109. #define DATA_LIMIT    1000*K    /* 1 MB */
  110. #endif
  111.  
  112. /* Initial size of k_data segment. */
  113.  
  114. #ifndef K_DATA_SIZE
  115. #define K_DATA_SIZE    64*K    /* 64 KB */
  116. #endif
  117.  
  118. /* Maximum size of k_data segment. */
  119.  
  120. #ifndef K_DATA_LIMIT
  121. #define K_DATA_LIMIT    1000*K    /* 1 MB */
  122. #endif
  123.  
  124. /* The stack grows down automatically. */
  125.  
  126. /* Initial size of stack segment. */
  127.  
  128. #ifndef STACK_SIZE
  129. #define STACK_SIZE    64*K    /* 64 KB */
  130. #endif
  131.  
  132. /* Maximum size of stack segment. */
  133.  
  134. #ifndef STACK_LIMIT
  135. #define STACK_LIMIT    256*K    /* 1 MB */
  136. #endif
  137.  
  138.  
  139. /* Name of the function to invoke at start up */
  140.  
  141. #define DEFAULT_RUN_LOCATION "__start"
  142.  
  143.  
  144. /* Default number of instructions to execute. */
  145.  
  146. #define DEFAULT_RUN_STEPS 2147483647
  147.  
  148.  
  149. /* Address to branch to when exception occurs */
  150.  
  151. #define EXCEPTION_ADDR 0x80000080
  152.  
  153.  
  154. /* Maximum size of object stored in the small data segment pointed to by
  155.    $gp */
  156.  
  157. #define SMALL_DATA_SEG_MAX_SIZE 8
  158.  
  159. #ifndef DIRECT_MAPPED
  160. #define DIRECT_MAPPED 0
  161. #define TWO_WAY_SET 1
  162. #endif
  163.  
  164.  
  165. /* Interval (in instructions) at which memory-mapped IO registers are
  166.    checked and updated.*/
  167.  
  168. #define IO_INTERVAL 100
  169.  
  170.  
  171. /* Number of instructions that a character remains in receiver buffer
  172.    if another character is available. (Should be multiple of IO_INTERVAL.) */
  173.  
  174. #define RECV_LATENCY (10*IO_INTERVAL)
  175.  
  176.  
  177. /* Number of instructions that it takes to write a character. (Should
  178.    be multiple of IO_INTERVAL.)*/
  179.  
  180. #define TRANS_LATENCY (IO_INTERVAL)
  181.  
  182.  
  183.  
  184. /* Triple containing a string and two integers.     Used in tables
  185.    mapping from a name to values. */
  186.  
  187. typedef struct strint
  188. {
  189.   char *name;
  190.   int value1;
  191.   int value2;
  192. } inst_info;
  193.  
  194.  
  195.  
  196. /* Exported functions (from spim.c or xspim.c): */
  197.  
  198. #ifdef __STDC__
  199. #ifndef SEEK_SET
  200. #include <stdio.h>
  201. #endif
  202.  
  203. int console_input_available (void);
  204. void control_c_seen (int);
  205. void error (char *fmt, ...);
  206. void fatal_error (char *fmt, ...);
  207. char get_console_char (void);
  208. void put_console_char (char c);
  209. void read_input (char *str, int n);
  210. int run_error (char *fmt, ...);
  211. void write_output (long, char *fmt, ...);
  212. #else
  213. int console_input_available ();
  214. void control_c_seen ();
  215. void error ();
  216. void fatal_error ();
  217. char get_console_char ();
  218. void put_console_char ();
  219. void read_input ();
  220. int run_error ();
  221. void write_output ();
  222. #endif
  223.  
  224.  
  225. /* Exported variables: */
  226.  
  227. extern int bare_machine;    /* Simulate bare instruction set */
  228. extern int quiet;        /* No warning messages */
  229. extern int source_file;        /* Program is source, not binary */
  230.  
  231. /* Actual type of structure pointed to depends on X/terminal interface */
  232. extern int message_out, console_out, console_in;
  233.  
  234. extern int mapped_io;        /* Non-zero => activate memory-mapped IO */
  235.  
  236. #ifdef CL_SPIM
  237. extern int pipe_out;
  238. extern int cycle_level;         /* non-zero => cycle level mode */
  239. #endif
  240.  
  241. extern mem_addr program_starting_address;
  242.  
  243. extern long initial_text_size;
  244.  
  245. extern long initial_data_size;
  246.  
  247. extern long initial_data_limit;
  248.  
  249. extern long initial_stack_size;
  250.  
  251. extern long initial_stack_limit;
  252.  
  253. extern long initial_k_text_size;
  254.  
  255. extern long initial_k_data_size;
  256.  
  257. extern long initial_k_data_limit;
  258.